package com.woniuxy.oa.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;

public class LoginHandlerInterceptor implements HandlerInterceptor{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		
		Object attribute = request.getSession().getAttribute("user");
		if(attribute!=null) {
			//true是放行
			return true;
		}else {
			//转发、重定向模板引擎不起作用
//			System.out.println("到1了");
			request.getRequestDispatcher("/index.html").forward(request, response);
			return false;
		}
	}
	
}
